package com.csweimei.rentmanagementtreasure.pop;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.house.AddZzZyHouseActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.house.HouseFollowRecordActivity;
import com.csweimei.rentmanagementtreasure.utils.permission.RxPermissionsUtils;
import com.lxj.xpopup.core.BottomPopupView;

import java.util.ArrayList;
import java.util.List;

public class PopEditHouse extends BottomPopupView {
    private Context mContext;


    private LinearLayout share,add_zy,add_gj,add_state;


    public PopEditHouse(@NonNull Context context) {
        super(context);
        this.mContext = context;
    }

    public PopSelClick mPopSelClick;
    public void setSelBack(PopSelClick popSelClick){
        this.mPopSelClick = popSelClick;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.pop_edit_house;
    }

    @Override
    protected void onCreate() {
        share = findViewById(R.id.share);
        add_zy = findViewById(R.id.add_zy);
        add_gj = findViewById(R.id.add_gj);
        add_state = findViewById(R.id.add_state);
        ImageView cancel = findViewById(R.id.pop_close);
        cancel.setOnClickListener(view -> dismiss());

        add_zy.setOnClickListener(v -> {
            if (type.equals("整租")){
                Intent intent = new Intent(mContext, AddZzZyHouseActivity.class);
                intent.putExtra("id",mId);
                mContext.startActivity(intent);
                dismiss();
            }

        });

        add_gj.setOnClickListener(v -> {
            Intent intent = new Intent(mContext, HouseFollowRecordActivity.class);
            intent.putExtra("id",mId);
            intent.putExtra("type",type);
            mContext.startActivity(intent);
            dismiss();
        });

        add_state.setOnClickListener(v -> {
            PopWheelBase popWheelBase = new PopWheelBase(mContext, 1, new PopWheelBase.Click() {
                @Override
                public void click(String s) {
                    if (mPopSelClick != null){
                        mPopSelClick.sel(new PopBean(s));
                    }
                }
            });
            List<String> list = new ArrayList<>();
            list.add("空置中");
            list.add("签约中");
            list.add("不可用");
            popWheelBase.setList1(list);
            PopUtils.showPop(mContext,popWheelBase,false);
            dismiss();
        });




    }

    public int mId = 0;
    public void setSelId(int id) {
        mId = id;
    }

    public String type = "整租";
    public void setSelType(String selType) {
        type = selType;
    }
}
